package com.chhlz.module.base.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.chhlz.module.base.dao.DishDao;
import com.chhlz.module.base.model.Dish;
import com.chhlz.module.service.DishService;


/**
 * 菜式业务
 * @author ALEXGORDON
 *
 */
@Service
public class DishServiceImpl implements DishService {
	@Autowired
	private DishDao DishDao;

	@Override
	public int getTotal() {
		return DishDao.countAll();
	}
	@Override
	public boolean isExist(String dishName) {
		boolean flag = false;
		String hql="from Dish as c where c.dishName="+dishName;
		if (DishDao.find(hql).size()>0){
			flag = true;
		}
		return flag;
	}
	@Override
	public int save(Dish t) {
		return this.DishDao.save(t);
	}
	@Override
	public void update(Dish t) {
		this.DishDao.update(t);
	}
	@Override
	public void delete(int id) {
		Dish d = this.DishDao.get(id);
		this.DishDao.delete(d);
	}
	@Override
	public List<Dish> findAll(int page, int rows, String sort, String order) {
		return this.DishDao.findAll(page, rows, sort, order);
	}
}
